package com.lanxin.xxform.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@RequestMapping("/home")
@Controller
public class HomeController {

    /**
     * 默认入库
     * @return
     */
    @GetMapping("")
    public String dashboard() {
        return "home/paper";
    }

    /**
     * 问卷管理
     * @return
     */
    @GetMapping("paper.html")
    public String paper(ModelMap map) {
        map.put("navIndex", "paper");
        return "home/paper";
    }

    /**
     * 问卷题目管理
     * @param id
     * @param map
     * @return
     */
    @GetMapping("subject.html/{id}")
    public String subject(
        @PathVariable String id,
        ModelMap map
    ) {
        map.put("navIndex", "paper");
        map.put("paperId", id);
        return "home/subject";
    }
    
    /**
     * 答卷管理
     * @return
     */
    @GetMapping("answer.html")
    public String answer(
        @RequestParam(defaultValue = "") String pid,
        ModelMap map
    ) {
        map.put("pid", pid);
        map.put("navIndex", "answer");
        return "home/answer";
    }
}
